<%--
*
* 描述：左边文件
*
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.sky.common.string.StringUtils"/>
<jsp:directive.page import="com.toncen.samepms.system.domain.Module"/>
<jsp:directive.page import="com.toncen.samepms.common.AbstractAction"/>
<jsp:directive.page import="com.toncen.samepms.basic.domain.User"/>
<jsp:directive.page import="com.toncen.samepms.system.domain.Role"/>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<%@include file="/share/header.jsp"%>
	<s:head/>
	<link href="<%=path%>/main/dsnc/css/frameCommon.min.css" rel="stylesheet" type="text/css">
	<link href="<%=path%>/main/dsnc/css/common.min.css" rel="stylesheet" type="text/css">
</head>
<!--[if IE 6]>
<style type="text/css">
div.btnWhite{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_white.png',sizingMethod="scale");}
div.btnWhiteHover{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_white_hover.png',sizingMethod="scale");}
div.btnWhiteClick{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_white_click.png',sizingMethod="scale");}
div.btnGreen{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_green.png',sizingMethod="scale");}
div.btnGreenHover{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_green.png_hover',sizingMethod="scale");}
div.btnGreenClick{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_green.png_click',sizingMethod="scale");}
</style>
<![endif]-->
<script>
	function onDoModifyUser(){
		var options={
			title:'【修改个人信息】',
			url:'<s:url action="edit" namespace='/basic/user'/>?modifySelf=true&domain.id='+<s:property value="currentUser.id"/>,
			source : window,
			buttons:[top.MyWindow.Save,top.MyWindow.Cancel],
			multiplewidth:1,
			multipleheight:1,
			tipstitle:'',
			tipscontent:'修改成功后下次登录才会生效；'
		};
		top.MyWindow.open(options);
	}
	function onDoLogout(){
		top.MyWindow.confirm({
			content : '你确实要注销吗？',
			title : '确认框',
			container : top,
			callback : function(action){
							if(action == 'ok'){//确定
								loading('<br><br><img src=\'<%=path%>/image/loading.gif\' ><br>我正在注销中，请稍候...<br><br>'); 
								top.indexFrame.document.location.replace('<s:url action="logout_dsnc" namespace="/main" />');
							}
						}	
		});
	}
</script>	
<body>
<div class="left">
  <div class="userInfo">
  <%
     User user=getCurrentUser(session);
     String userName=user.getName();
     String organizationName=user.getOrganization().getName();
     String roleName="";
     for(Role role:user.getRoles()){
     	roleName+="、"+role.getName();
     }
     roleName=roleName.replaceFirst("、","");
  %>
    <span title="用户：【<%=userName%>】&#10角色：【<%=roleName%>】&#10单位：【<%=organizationName%>】">
	    <table width="100%" border="0" cellspacing="0" cellpadding="0">
	      <tr>    
		    <td nowrap="true">
		    	<strong>用户:</strong>【<%=userName%>】
			</td>
		  </tr>
	      <tr>    
		    <td nowrap="true">
		    <strong>角色:</strong>【<%=(roleName.length()>6?roleName.substring(0,5)+"...":roleName)%>】<br/>
			</td>
		  </tr>
	      <tr>    
		    <td nowrap="true">
		    <strong>单位:</strong>【<%=(organizationName.length()>6?organizationName.substring(0,5)+"...":organizationName)%>】
			</td>
		  </tr>
	    </table>	    
    </span>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="40"><div class="btnWhite" title="注销当前用户" onMouseOver="this.className='btnWhiteHover'" onMouseOut="this.className='btnWhite'" onMouseDown="this.className='btnWhiteClick'" onMouseUp="this.className='btnWhiteHover'" onclick="onDoLogout()">注销退出</div></td>
        <td><div class="btnWhite" title="修改个人信息" onMouseOver="this.className='btnWhiteHover'" onMouseOut="this.className='btnWhite'" onMouseDown="this.className='btnWhiteClick'" onMouseUp="this.className='btnWhiteHover'" onclick="onDoModifyUser()">修改帐户</div></td>
      </tr>
    </table>
  </div>
  <div class="leftMenuBg">
  <div class="leftMenu">
  <%
  	String menuId=request.getParameter("menuId");//获取传递过来的一级模块id
  	if(!StringUtils.isEmpty(menuId)){
	  	Object modules=session.getAttribute(AbstractAction.MODULE_SESSION_ATTRIBUTE);//获取session中保存的功能权限
	  	if(modules==null){
	  		throw new Exception("未设置当前登录用户的功能权限，请与系统管理员联系！");
	  	}
	  	List<Module>  moduleList = (List)modules;
	  	Module module= null;
	  	for(Module m : moduleList){//遍历一级模块
	  		if(Long.parseLong(menuId)==m.getId()){
	  			module=m;
	  			break;
	  		}
	  	}
	  	if(module==null){
	  		throw new Exception("当前登录用户的功能权限未找到功能模块【"+menuId+"】，请与系统管理员联系！");
	  	}	  	
  		for(Module m : module.getChilds()){//遍历二级模块
  %>
  			<div class="leftMenuTitle" title="<%=m.getName()%>" <%if(!StringUtils.isEmpty(m.getLinkUrl())){%> <%}%> ><%=m.getName()%><%if(!StringUtils.isEmpty(m.getLinkUrl())){%>&nbsp;&nbsp;<img src="<%=path%>/main/dsnc/image/tooltip.gif" width="14" height="14"  onclick="top.indexFrame.mainFrame.onDoModule('<%=m.getId()%>','<%=m.getName()%>','<%=module.getName()+">>"+m.getName()%>','<%=m.getLinkUrl()%>')"/>&nbsp;&nbsp;<%}%></div>	
  				<ul>
  <%
	  		for(Module c : m.getChilds()){//遍历三级级模块
  %>
					<li title="<%=c.getName()%>" onClick="top.indexFrame.mainFrame.onDoModule('<%=c.getId()%>','<%=c.getName()%>','<%=module.getName()+">>"+m.getName()+">>"+c.getName()%>','<%=c.getLinkUrl()%>')"><div class="leftMenuList"><%=c.getName()%></div></li>  			
  <%					  			
	  		}  
  %>
  				</ul>	
  <%	  					
  		}
  	}
  %>
</div>
</div>
</body>
</html>
<script>
$(function(){
	InitialMyTree();
	onDoResize();
	$(window).resize(onDoResize);
});
function onDoResize(){
  if($(".leftMenuBg").height()!=document.documentElement.offsetHeight-87-12){
  	//alert("resize left");
	$(".leftMenuBg").height(document.documentElement.offsetHeight-87-12);
  }
}
function InitialMyTree(){//初始化树控件 添加点击事件 添点菜单出现的动画
	$(".leftMenu ul").css("display","none");
	var p_Tree = $(".leftMenu>div");
	p_Tree.bind("mouseover",function(){
		this.className = "leftMenuTitleHover";
	}).bind("mouseout",function(){
		if(!this.clicked){
			this.className = "leftMenuTitle";
		}else{
			this.className = "leftMenuTitleSelected";
		}
	});
	
	var childTree = $(".leftMenu ul li>div");
	childTree.bind("mouseover",function(){
		if(!this.clicked)
			this.className = "leftMenuListHover";
	}).bind("mouseout",function(){
		if(!this.clicked)
			this.className = "leftMenuList";
	}).bind("click",function(){
		childTree.each(function(){
			this.className = "leftMenuList";
			this.clicked = false;			
		});	
		this.clicked = true;
		this.className = "leftMenuListHover";//---在这里写点击样式
	});
	
	p_Tree.bind("click",function(){
		p_Tree.each(function(){//将所有点击样式去掉
			this.className = "leftMenuTitle";
			this.clicked = false;
		});
			
		$(p_Tree).next("ul").each(function(){
			$(this).css("display","none");
		});
		$(this).next("ul").slideDown("normal");
		$(this).get(0).className = "leftMenuTitleSelected";
		this.clicked = true;
	});
	
	$(".leftMenu > :first-child").trigger("click");
		
}
</script>
